﻿using B.S.DataBase.MyProject.Domain.procedure;
using B.S.DataBase.MyProject.ErrorCode;
using B.S.DataBase.MyProject.Infrastructure.Interface;
using MediatR;
using T.E.ERP.Read.API.Applicantions.Command.GetrovalCommand;

namespace T.E.ERP.Read.API.Applicantions.CommandHandler.GetrovalCommandHandler
{
    /// <summary>
    /// 流程管理
    /// </summary>
    public class GetvalCommdHander : IRequestHandler<GetvalCommd, APIResult<List<ApprovalTrail>>>
    {

        private readonly IBaseRepository<ApprovalTrail> baseRepository;

        public GetvalCommdHander(IBaseRepository<ApprovalTrail> baseRepository)
        {
            this.baseRepository = baseRepository;
        }



        /// <summary>
        /// 处理
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public Task<APIResult<List<ApprovalTrail>>> Handle(GetvalCommd request, CancellationToken cancellationToken)
        {
            APIResult<List<ApprovalTrail>> result  =new APIResult<List<ApprovalTrail>>();
            result.Code =APIEnum.查询成功;
            result.Msg =APIEnum.查询成功.ToString();

            

            var list = baseRepository.GetAll().Result;

            result.data = list.ToList();
            

            return Task.FromResult(result);
        }
    }
}
